#!/usr/bin/env python
# -*- coding: utf-8 -*-

# @Time     :2020/09/15
# @Author   :Changshu
# @File     :practice_118.py
# 给定一个非负整数 numRows，生成杨辉三角的前 numRows 行。

def generate(numRows: int) -> list:
	if numRows<=0:
		return []
	result=[]
	row=1
	while row<=numRows:
		i=0
		oneFloor=[]
		while i <row:
			if i==0:
				oneFloor.append(1)
			elif i==row-1:
				oneFloor.append(1)
			else:
				oneFloor.append(result[row-2][i-1]+result[row-2][i])
			i+=1
		result.append(oneFloor)
		row+=1
	return result


if __name__ == '__main__':
	r=generate(5)
	print(r)